-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework load progress dialog #918
base: master
Are you sure you want to change the base?
Conversation
8da04dc
to
6ae6d96
Compare
6ae6d96
to
3691dfd
Compare
@nfi after the latest changes, this should work better since the AWT thread isn't as contended as before. |
Looks better. There are no longer any problems interacting with the progress dialog under macOS. Some things I noticed:
|
3691dfd
to
fad0b50
Compare
The first issue is fixed, was missing a setProgress when restarting/cancelling. The second issue is hard to reproduce, even when I limit my CPU to 1700 MHz. I fixed the issue I found. |
0612e11
to
920154c
Compare
920154c
to
c79f71e
Compare
The last revision worked, but I think the commit history had some rebase-leftovers. Fixed that, and everything should work in this revision. |
c79f71e
to
a014273
Compare
progressDialog.setLocationRelativeTo(frame); | ||
progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); | ||
final String progressTitle = "Loading " + (configFile == null ? cooja.getSimulation().getCfg().file() : configFile.getAbsolutePath()); | ||
progressMonitor = new ProgressMonitor(frame, progressTitle, "", 0, 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note with empty string takes no space and ProgressMonitor does not revalidate if a note is added later. Add an initial note to reserve space for notes in the dialog. Otherwise the 'Cancel' button is truncated in some UI such as Flatlaf.
progressMonitor = new ProgressMonitor(frame, progressTitle, "", 0, 6); | |
progressMonitor = new ProgressMonitor(frame, progressTitle, "Preparing to load simulation", 0, 6); |
progressDialog.getRootPane().setDefaultButton(button); | ||
progressDialog.setLocationRelativeTo(frame); | ||
progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); | ||
final String progressTitle = "Loading " + (configFile == null ? cooja.getSimulation().getCfg().file() : configFile.getAbsolutePath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps set a better title on the progress monitor? Otherwise the title in, for example, a Swedish system will be 'Pågår'.
final String progressTitle = "Loading " + (configFile == null ? cooja.getSimulation().getCfg().file() : configFile.getAbsolutePath()); | |
final String progressTitle = "Loading " + (configFile == null ? cooja.getSimulation().getCfg().file() : configFile.getAbsolutePath()); | |
final String defaultTitle = UIManager.getString("ProgressMonitor.progressText"); | |
UIManager.put("ProgressMonitor.progressText", "Loading simulation"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The max progress includes any deprecated plugins. Not that it will make a noticeable difference, but should there not be a Cooja.tickProgress();
before line 360 to count skipped plugins?
progressMonitor = new ProgressMonitor(frame, progressTitle, "", 0, 6); | ||
progressMonitor.setMillisToDecideToPopup(0); | ||
progressMonitor.setMillisToPopup(0); | ||
progressMonitor.setProgress(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore original title for ProgressMonitor if it was changed earlier.
progressMonitor.setProgress(0); | |
progressMonitor.setProgress(0); | |
UIManager.put("ProgressMonitor.progressText", defaultTitle); |
This uses the Java builtin ProgressMonitor class. As an additional bonus, this makes the cancel button work.